import request from "@/utils/request";
import type { RequestParams, ResponseData, shelfRequestParams } from "./type";

// 分页列表
export const BookshelfList = (data: RequestParams) => {
  return request<ResponseData<shelfRequestParams>>({
    url: "/api/v1/bookshelf/page",
    method: "post",
    data,
    headers: {
      //需要加密的请求在头部塞入标识
      isEncrypt: 1,
    },
  });
};
export const addBookshelf = (data: shelfRequestParams) => {
  return request<ResponseData<shelfRequestParams>>({
    url: "/api/v1/bookshelf/add",
    method: "post",
    data,
    headers: {
      //需要加密的请求在头部塞入标识
      isEncrypt: 1,
    },
  });
};
export const batchAddBookshelf = (data: shelfRequestParams) => {
  return request<ResponseData<shelfRequestParams>>({
    url: "/api/v1/bookshelf/batchAdd",
    method: "post",
    data,
    headers: {
      //需要加密的请求在头部塞入标识
      isEncrypt: 1,
    },
  });
};

export const delBookshelf = (id: number) => {
  return request<ResponseData<shelfRequestParams>, any>({
    url: "/api/v1/bookshelf/delete",
    method: "post",
    data: id,
    headers: {
      //需要加密的请求在头部塞入标识
      isEncrypt: 1,
    },
  });
};
export const FormBookshelf = (id: number) => {
  return request<ResponseData<shelfRequestParams>>({
    url: "/api/v1/bookshelf/form",
    method: "post",
    data: id,
    headers: {
      //需要加密的请求在头部塞入标识
      isEncrypt: 1,
    },
  });
};

export const BookshelfOptions = (aesKeyByRsa: string) => {
  return request<ResponseData<any>>({
    url: "/api/v1/bookshelf/options",
    method: "post",
    data: aesKeyByRsa,
    headers: {
      //需要加密的请求在头部塞入标识
      isEncrypt: 1,
    },
  });
};
export const updateBookshelf = (data: shelfRequestParams) => {
  return request<ResponseData<shelfRequestParams>>({
    url: "/api/v1/bookshelf/update",
    method: "post",
    data,
    headers: {
      //需要加密的请求在头部塞入标识
      isEncrypt: 1,
    },
  });
};
export const syncBook = (data: BookRequestParams) => {
  return request<ResponseData<BookRequestParams>, any>({
    url: "/api/v1/bookshelf/syncShelf",
    method: "post",
    data,
    headers: {
      //需要加密的请求在头部塞入标识
      isEncrypt: 1,
    },
  });
};
export const StandardOptions = (aesKeyByRsa: string) => {
  return request<ResponseData<any>>({
    url: "/api/v1/bookshelfStandard/options",
    method: "post",
    data: aesKeyByRsa,
    headers: {
      //需要加密的请求在头部塞入标识
      isEncrypt: 1,
    },
  });
};
